package com.emperor.controller.vmservice;

import com.emperor.entity.VmType;
import com.emperor.result.Result;
import com.emperor.service.VmTypeService;
import com.emperor.vo.SkuClassPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "设备类型管理")
@RestController
@RequestMapping("/vm-service/vmType")
public class VmTypeController {
    @Autowired
    private VmTypeService vmTypeService;

    @ApiOperation("设备搜索分页查询")
    @GetMapping("/search2")
    public Result<SkuClassPageVo> findAll(Integer pageIndex, Integer pageSize, String className) {
        SkuClassPageVo vo = vmTypeService.findAll(pageIndex, pageSize, className);
        return Result.success(vo);
    }

    @PostMapping
    @ApiOperation("新增设备类型")
    public Result addVmType(@RequestBody VmType vmType) {
        vmTypeService.addVmType(vmType);
        return Result.success();
    }

    @PutMapping("/{typeId}")
    @ApiOperation("修改设备类型")
    public Result updateVmType(@PathVariable Integer typeId, @RequestBody VmType vmType) {
        vmTypeService.updateVmType(typeId, vmType);
        return Result.success();
    }

    @DeleteMapping("/{typeId}")
    @ApiOperation("删除设备类型")
    public Result deleteVmType(@PathVariable Integer typeId) {
        vmTypeService.deleteVmType(typeId);
        return Result.success();
    }
}
